﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using vensoft.Entities;
using vensoft.BussinesLogic;

namespace vensoft.Win32
{
    public partial class frmMostrarHistoricoTransf : Form
    {
        IHistoricoBL historicoBL;

        public frmMostrarHistoricoTransf()
        {
            InitializeComponent();
            historicoBL = new HistoricoBL();
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmMostrarHistoricoTransf_Load(object sender, EventArgs e)
        {
            historicoBindingSource.DataSource = historicoBL.GetAllFromHistorico();
            rdbFechas.Checked = true;
            txtCodigoProducto.Visible = false;
            lblCod_Prod.Visible = false;
        }

        private void btnMostrarTodo_Click(object sender, EventArgs e)
        {
            historicoBindingSource.DataSource = historicoBL.GetAllFromHistorico();
        }

        private void btnBuscarVenta_Click(object sender, EventArgs e)
        {
            if(rdbFechas.Checked == true)            
            {
                historicoBindingSource.DataSource = historicoBL.GetAllFromHistoricoByFechas((Convert.ToDateTime(dtpDesde.Value.ToString())).AddDays(-1), Convert.ToDateTime(dtpHasta.Value.ToString()));
            }
            else if (rdbCodigo.Checked == true)
            {
                historicoBindingSource.DataSource = historicoBL.GetAllFromHistoricoByCodProd(txtCodigoProducto.Text);
            }
        }

        private void rdbCodigo_CheckedChanged(object sender, EventArgs e)
        {
            if (rdbCodigo.Checked == true)
            {
                dtpDesde.Visible = false;
                dtpHasta.Visible = false;
                lblDesde.Visible = false;
                lblHasta.Visible = false;
                lblCod_Prod.Visible = true;
                txtCodigoProducto.Visible = true;
            }
            else if (rdbFechas.Checked == true)
            {
                dtpDesde.Visible = true;
                dtpHasta.Visible = true;
                lblDesde.Visible = true;
                lblHasta.Visible = true;
                lblCod_Prod.Visible = false;
                txtCodigoProducto.Visible = false;
            }
        }
    }
}
